package com.xc.c1

object ext01 {

  class Person(inName: String, inAge: Int) {
    var name = inName
    var age = inAge

    def info: Unit = {
      println(s"学生信息 name = $name,age = $inAge")
    }

    def eat: Unit = {
      println("早饭在家吃...")
    }

    def this() {
      this("", 0)
    }
  }

  class Student(name: String, age: Int) extends Person {
    def study: Unit = {
      println(s"$name 开始学习...")
    }

    override def eat: Unit = {
      super.eat
      println("中饭在外面吃...")
    }
  }

  def main(args: Array[String]): Unit = {
    val student = new Student("hxc", 18)
    student.study
    student.eat
    val person = student.asInstanceOf[Person]
  }

}
